const axios = require('axios');

// 模拟ApiClient的配置
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:7172/api';
const baseURL = apiUrl.startsWith('http') ? apiUrl : `https://${apiUrl}`;

console.log('Environment Variable:', process.env.NEXT_PUBLIC_API_URL);
console.log('Resolved apiUrl:', apiUrl);
console.log('Final baseURL:', baseURL);

const client = axios.create({
  baseURL: baseURL,
  timeout: 5000
});

// 添加请求拦截器来显示完整URL
client.interceptors.request.use(config => {
  console.log('Base URL:', config.baseURL);
  console.log('Request URL:', config.url);
  console.log('Full URL would be:', `${config.baseURL}/${config.url}`);
  return config;
});

// 测试buyToken调用
client.post('bonding-curve/buy', {
  tokenMint: 'test',
  solAmount: 1,
  buyerPublicKey: 'test'
}).catch(err => {
  console.log('请求状态:', err.response?.status || 'network error');
  console.log('响应数据:', err.response?.data || err.message);
});
